package com.suncreate.zhtz.iot.service.impl;

import com.suncreate.zhtz.iot.mapper.ScWarningStrategyDao;
import com.suncreate.zhtz.iot.model.ScWarningStrategy;
import com.suncreate.zhtz.iot.service.ScWarningStrategyService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 预警策略配置列表(ScWarningStrategy)表服务实现类
 *
 * @author makejava
 * @since 2021-09-07 11:13:37
 */
@Service("scWarningStrategyService")
public class ScWarningStrategyServiceImpl implements ScWarningStrategyService {
    @Resource
    private ScWarningStrategyDao scWarningStrategyDao;

    /**
     * 通过ID查询单条数据
     *
     * @param straId 主键
     * @return 实例对象
     */
    @Override
    public ScWarningStrategy queryById(Integer straId) {
        return this.scWarningStrategyDao.queryById(straId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<ScWarningStrategy> queryAllByLimit(int offset, int limit) {
        return this.scWarningStrategyDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param scWarningStrategy 实例对象
     * @return 实例对象
     */
    @Override
    public ScWarningStrategy insert(ScWarningStrategy scWarningStrategy) {
        this.scWarningStrategyDao.insert(scWarningStrategy);
        return scWarningStrategy;
    }

    /**
     * 修改数据
     *
     * @param scWarningStrategy 实例对象
     * @return 实例对象
     */
    @Override
    public ScWarningStrategy update(ScWarningStrategy scWarningStrategy) {
        this.scWarningStrategyDao.update(scWarningStrategy);
        return this.queryById(scWarningStrategy.getStraId());
    }

    /**
     * 通过主键删除数据
     *
     * @param straId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer straId) {
        return this.scWarningStrategyDao.deleteById(straId) > 0;
    }

    @Override
    public List<ScWarningStrategy> queryAll(ScWarningStrategy scWarningStrategy) {
        return this.scWarningStrategyDao.queryAll(scWarningStrategy);
    }

    @Override
    public List<String> queryTopicnameBySavelocation(String saveLocation) {
        return this.scWarningStrategyDao.queryTopicnameBySavelocation(saveLocation);
    }
}
